#include "basic.h"

basic::basic()
{
    setWindowTitle("添加基站");
    QVBoxLayout *vbox =new QVBoxLayout;

    QFormLayout *form =new QFormLayout;
    name =new QLineEdit;
    address =new QLineEdit;
    form->addRow("名称",name);
    form->addRow("所在地",address);
    vbox->addLayout(form,4);
    QHBoxLayout *hbox =new QHBoxLayout;
    submit =new QPushButton("确定");
    cancel =new QPushButton("取消");
    hbox->addWidget(submit);
    hbox->addWidget(cancel);
    vbox->addLayout(hbox,1);
    this->setLayout(vbox);
    QObject::connect(cancel,&QPushButton::clicked,this,&basic::close);
    QObject::connect(submit,&QPushButton::clicked,this,&basic::savemess);
}

void basic::savemess()
{
    emit closeBox();
    QFile file("basic.txt");
    file.open(QIODevice::Append);//以添加方式打开文件
    QDataStream write(&file);
    write<<this->name->text()<<this->address->text();
    file.close();
    this->close();
}

QString basic::getname()
{
    return name->text();
}

QString basic::getaddress(){return address->text();}


